package com.example.demo.Utils;

import com.alibaba.excel.EasyExcel;
import com.example.demo.Entity.Person;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Date;
import java.util.List;

/**
 * CSVUtils
 *
 * @blame Android Team
 */
public class CSVUtils {
    public static void  downloadPerson(HttpServletResponse response, Class t, List list,  String fileName) throws IOException {
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-Disposition", "attachment;filename="+fileName);
        ServletOutputStream servletOutputStream =response.getOutputStream();
        EasyExcel.write(servletOutputStream, t).sheet("demo").doWrite(list);
    }

}
